﻿<!DOCTYPE html>
<html><head>
<meta charset="UTF-8">
<title>图书详情</title>
<link type="text/css" rel="stylesheet" href="css/index.css">
<script src="js/jquery-3.4.1.js"></script>
<style>
#grade {
	height: 34px
}

#grade>ul {
	height: 18px
}

#grade>ul>li {
	margin: 0
}
</style>
</head>
<body class="index">
	<div id="content"></div>
	<div class="container">
		<header>

		</header>
<!--		<div class="header" id="header">-->
<!--			<h1 class="logo">-->
<!--				<a title="" style="background: url(images/logo.png);" href="index.jsp">电子商务平台</a>-->
<!--			</h1>-->
<!--			&lt;!&ndash; <ul class="shortcut">-->
<!--				<li class="first"><a href="ucenter/">个人中心</a></li>-->
<!--				<li><a href="ucenter/">我的订单</a></li>-->
<!--			</ul>-->
<!--			<p class="loginfo">-->


<!--				[<a href="login.html">登录</a> <a class="reg" href="register.html">免费注册</a>]-->

<!--			</p> &ndash;&gt;-->
<!--		<ul class="shortcut"><li class="first"><a href="personal.html">个人中心</a></li><li><a href="myOrders.html">我的订单</a></li></ul><p class="loginfo">你好!17760990684[<a href="javaScript:logout()">安全退出</a>]</p></div>-->
<!--		<div class="navbar">-->
<!--			<ul id="goodsType">-->
<!--				<li><a href="#">首页</a></li>-->
				<!-- <li><a href="#">IT技术</a></li>
				<li><a href="#">小说文学</a></li>
				<li><a href="#">历史传记</a></li>
				<li><a href="#">生活</a></li>
				<li><a href="#">经营管理</a></li> -->
<!--			 <li><a href="goods.html?gtid=1">IT技术</a></li> <li><a href="goods.html?gtid=2">历史传记</a></li> <li><a href="goods.html?gtid=3">小说</a></li> <li><a href="goods.html?gtid=4">生活</a></li> <li><a href="goods.html?gtid=5">经营管理</a></li>
-->
<!--		</ul>-->
<!--			<div class="mycart">-->
<!--				<dl>-->
<!--					<dt>-->
<!--						<a href="cart.jsp">购物车<b name="mycart_nums" id="mycart_nums">0</b>件-->
<!--						</a>-->
<!--					</dt>-->
<!--					<dd>-->
<!--						<a href="cart.jsp">去结算</a>-->
<!--					</dd>-->
<!--				</dl>-->
<!--				&lt;!&ndash;购物车浮动div 开始&ndash;&gt;-->
<!--				<div class="shopping" id="div_mycart" style="display: none;">-->
<!--					<dl class="cartlist" id="shopcarDiv">-->
<!--					</dl>-->
<!--				</div>-->

<!--			</div>-->
<!--		</div>-->
<!--		<div class="searchbar">-->
<!--			<div class="allsort">-->
<!--				<a href="javascript:void(0);">全部商品分类</a>-->
<!--				&lt;!&ndash;总的商品分类-开始&ndash;&gt;-->
<!--				<ul class="sortlist" id="div_allsort" style="display: none"><li><h2><a href="goods.html?gtid=1">IT技术</a></h2></li><li><h2><a href="goods.html?gtid=2">历史传记</a></h2></li><li><h2><a href="goods.html?gtid=3">小说</a></h2></li><li><h2><a href="goods.html?gtid=4">生活</a></h2></li><li><h2><a href="goods.html?gtid=5">经营管理</a></h2></li></ul>-->
<!--			</div>-->
<!--			<script>-->
<!--				-->
<!--			</script>-->

<!--			<div class="searchbox">-->
<!--				<input class="text" type="text" name="q" autocomplete="off" placeholder="输入关键字..." id="word"> <input class="btn" type="button" value="商品搜索" id="search-btn">-->

<!--			</div>-->
<!--			<div class="hotwords">-->
<!--				热门搜索：IT-->
<!--			</div>-->
<!--		</div>-->
		<div class="wrapper clearfix">
			<div class="summary">

				<h2 id="title"></h2>
				<!--基本信息区域-->
				<ul id="infor">

					<li>
						<span class="f_r light_gray">图书编号：
							<label id="data_goodsNo">
							</label>
						</span>
					</li>

					<li id="priceLi">
					销售价：￥
					<b class="price red2">
						<span class="f30" id="real_price"></span>
					</b>
					</li>

					<li>市场价：￥
					<del id="data_marketPrice">
					</del>
					</li>

					<li id="data_author">作者:</li>
					<li id="data_publisher">出版社：</li>
					<li id="data_pubtime">出版时间：</li>

					<li>库存：现货
						<span>
							(<label id="data_storeNums"></label>)
						</span>
					</li>
				</ul>

				<div class="current">
					<dl class="m_10 clearfix">
						<dt>购买数量：</dt>
						<dd>
							<input class="gray_t f_l" type="text" id="buyNums" value="1" maxlength="5">
							<div class="resize">
								<a class="add"></a>
								<a class="reduce"></a>
							</div>
						</dd>
					</dl>
					<input class="submit_buy" type="button" id="buyNowBtn" value="立即购买">
					<div class="shop_cart" style="z-index: 1">
						<input class="submit_join" type="button" id="joinCarBtn" value="加入购物车">
						<div class="shopping" id="product_myCart" style="display: none">
							<dl class="cart_stats">
								<dt class="gray f14 bold">
									<a class="close_2 f_r" href="javascript:closeCartDiv();" title="关闭">关闭</a> <img src="images/front/right_s.gif" width="24" height="24" alt="">成功加入购物车
								</dt>
								 <dd class="gray">
									目前选购商品共<b class="orange" name='mycart_count'></b>件<span>合计：<b
										name='mycart_sum'></b></span>
								</dd>
								<dd>
									<a class="btn_blue bold" href="cart?opr=view">进入购物车</a><a class="btn_blue bold" href="javascript:void(0)" onclick="closeCartDiv();">继续购物&gt;&gt;</a>
								</dd>
							</dl>
						</div>
					</div>
				</div>
			</div>

			<div id="image">

			</div>
		</div>

		<div class="wrapper clearfix container_2">
			<!--左边栏-->
			<div class="sidebar f_l">
				<!-- 				<div class="box m_10">
					<div class="title">购买本商品的用户还购买过</div>
					<div class="content">
						<ul class="ranklist">
							<li class="current"><a
								href="/shop/index.php?controller=site&action=products&id=1"><img
									width="58px" height="58px" src="/shop/"></a> <a
								title="Java编程思想" class="p_name"
								href="/shop/index.php?controller=site&action=products&id=1">Java编程思想</a>
								<b>￥89.00</b></li>
						</ul>
					</div>
				</div> -->
			</div>


		</div>
		<footer>
		</footer>
	</div>
   <script src="js/include.js"></script>
	<script>
		$(function(){
			var user=JSON.parse(window.sessionStorage.getItem("user"));
			var ids=location.href.split("=")[1];
			console.log(ids)
			$.ajax({
				url:"goods.do",
				data: {
					method:"goodsDetail",
					id:ids,
				},
				dataType:"json",
				type:"get",
				success:function(result){
					var goods=result.data;
					if(result.code==200){
						$("#title").append(goods.name.substring(0,goods.name.length/2)+"....");
						$("#data_goodsNo").append(goods.goodsno);
						$("#real_price").append(goods.salesprice);
						$("#data_marketPrice").append(goods.marketprice);
						$("#data_author").append(goods.author);
						$("#data_publisher").append(goods.publisher);
						$("#data_pubtime").append(goods.pubtime);
						$("#data_storeNums").append(goods.stock);
						$("#image").append("<div class=\"pic_show\" style=\"width: 335px; height: 335px; position: relative; z-index: 5; padding-bottom: 5px;\">\n" +
								"\t\t\t\t\t<img src="+goods.image+" title="+goods.name.substring(0,goods.name.length/2)+" style=\"border: none; width: 335px; height: 335px\" id=\"pic\">\n" +
								"\t\t\t\t</div>");
					}
				}
			})
			$(".add").click(function (event) {
				event.preventDefault();
				alert(parseInt($("#buyNums").val())+1);
				$("#buyNums").val(parseInt($("#buyNums").val())+1);
			})
			$(".reduce").click(function (event) {
				event.preventDefault();
				alert();
				$("#buyNums").val($("#buyNums").val()-1);
			})
			/**
			 * 添加购物车
			 */
			$(":button").click(function (event){
				event.preventDefault();
				if(user!=null) {
					$.ajax({
						url: "Cart.do",
						data: {
							method: "addBy",
							nums: $("#buyNums").val(),
							goodsid: ids,
							userid: user.id,
							price: $("#real_price").text(),
						},
						dataType: "json",
						type: "get",
						success: function (result) {
							if (result.code == 200) {
								alert(result.msg);
							}
						}
					})
				}else {
					alert("未登录！");
				}
			})
		})
	</script>

</body></html>
